import Vue from 'vue';
import Router from 'vue-router';

/**
 * import pages to config router
 */
// import layout from '../view/layout/Layout.vue';
// import login from '../view/account/login.vue'
// import dashboard from '../view/dashboard.vue';
// import post from '../view/post/post.vue';
// import review from '../view/review/review.vue';

//page
const layout = resolve => require(['../view/layout/Layout.vue'], resolve);
const login = resolve => require(['../view/account/login.vue'], resolve);
const dashboard = resolve => require(['../view/dashboard.vue'], resolve);
const post = resolve => require(['../view/post/post.vue'], resolve);
const review = resolve => require(['../view/review/review.vue'], resolve);
const register = resolve => require(['../view/account/register.vue'], resolve);
const adminSelf = resolve => require(['../view/admin/adminSelf.vue'], resolve);
const configuration = resolve => require(['../view/admin/configuration.vue'], resolve);
const adminPrivileges = resolve => require(['../view/admin/adminPrivileges.vue'], resolve);
const adminGroup = resolve => require(['../view/admin/adminGroup.vue'], resolve);
const adminGroupProperties = resolve => require(['../view/admin/adminGroupProperties.vue'], resolve);


// const data_user = resolve => require(['../view/data/user.vue'], resolve);
// const data_userInAct = resolve => require(['../view/data/userInAct.vue'], resolve);
// import userInAcademy from '../view/data/userInAcademy.vue';

import {checkLogin} from './LoginHook'

Vue.use(Router);

export default new Router({
  mode: 'history',
  routes: [{
    path: '/login',
    name: "login",
    component: login,
  }, {
    path: '/register',
    name: "register",
    component: register,
  }, {
    path: '/',
    component: layout,
    beforeEnter: checkLogin,
    children: [
      /**
       * 数据管理
       */
      {
        path: 'post/:groupId',
        component: post,
        name: 'post',
      },
      {
        path: 'review/:userId/:groupId/:year/:week',
        component: review,
        name: 'review',
      }, {
        path: 'admin-group/:groupId',
        component: adminGroupProperties,
        name: 'adminGroupProperties'
      }, {
        path: 'admin-group',
        component: adminGroup,
        name: 'adminGroup'
      }, {
        path: 'admin-self',
        component: adminSelf,
        name: 'adminSelf'
      }, {
        path: 'admin-privileges',
        component: adminPrivileges,
        name: 'adminPrivileges'
      }, {
        path: 'admin-config',
        component: configuration,
        name: 'config'
      }, {
        path: '',
        component: dashboard,
        name: "main",
      }
    ]
  }]
});


